package com.econ.powercloud.ems.dal.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.econ.powercloud.ems.dal.entity.EmsProductLocationConfig;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * ems关于产品遥测遥信对应位置信息配置表 Mapper 接口
 * </p>
 *
 * @author AutoGenerator
 * @since 2021-11-17
 */
public interface EmsProductLocationConfigMapper extends BaseMapper<EmsProductLocationConfig> {

    /**
     * 通过储能站id与储能装置编号与页面位置相获取对应的遥调遥控设置值
     * @param locations
     * @return
     */
   /* @Select("SELECT * FROM ems_product_location_config as a WHERE location in " +
            "<foreach item = 'item' index = 'index' collection = 'locations' open = '('separator=','close=')'> #{item} </foreach> " +
            "ORDER BY CAST(a.sorting AS DECIMAL) ASC")*/
    @Select("<script>" +
            "select " +
            "* " +
            "from ems_product_location_config as a " +
            "WHERE a.location in " +
            "<foreach item='item' index='index' collection='locations' open='(' separator=',' close=')'>" +
            "#{item}" +
            "</foreach> " +
            "<if test = 'virtual != null'>" +
            "AND virtual = #{virtual} " +
            "</if> " +
            "ORDER BY CAST(a.sorting AS DECIMAL) ASC"+
            "</script>")
    List<EmsProductLocationConfig> getMapByLocationSort(@Param("locations") List<Integer> locations, @Param("virtual") Integer virtual);

}
